@echo off

setlocal enabledelayedexpansion

uv export --no-hashes -o requirements-autogen.txt

uv pip freeze > requirements-dev-autogen.txt

set PYTHON_CACHE_DIR_PATH="%PYTHON_CACHE_DIR%"

if  %PYTHON_CACHE_DIR_PATH% == "" (

echo system variable PYTHON_CACHE_DIR is not defined ! 

echo please check again!"

@pause

exit /b

)

if not exist .python-version (

echo Error: .python-version file not found.

exit /b

)

for /f "delims=" %%v in (.python-version) do (

set "PYTHON_VERSION=%%v"

)


if not defined PYTHON_VERSION (

echo Error: No version found in .python-version file.

exit /b

)

for /f "tokens=1,2 delims=." %%a in ("%PYTHON_VERSION%") do (

set MAJOR=%%a

set MINOR=%%b

)

if not defined MAJOR (

echo Error: Invalid version format.

exit /b

)

if not defined MINOR (

echo Error: Version must include major and minor version numbers.

exit /b

)

set "PYTHON_VERSION_SHORT=%MAJOR%.%MINOR%"

echo python version: "%PYTHON_VERSION_SHORT%"

python  -m pip download --no-cache-dir -r requirements-autogen.txt -d %PYTHON_CACHE_DIR_PATH% 

python  -m pip download --no-cache-dir -r requirements-autogen.txt -d %PYTHON_CACHE_DIR_PATH%  --python-version "%PYTHON_VERSION_SHORT%"  --only-binary=:all:

python  -m pip download --no-cache-dir -r requirements-dev-autogen.txt -d %PYTHON_CACHE_DIR_PATH%

python  -m pip download --no-cache-dir -r requirements-dev-autogen.txt -d %PYTHON_CACHE_DIR_PATH% --python-version "%PYTHON_VERSION_SHORT%"  --only-binary=:all:

@pause